package br.infotec.musicaunb.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.search.annotations.DocumentId;
import org.springframework.data.jpa.domain.AbstractPersistable;

@Entity
@Table(name = "login")
public class Login extends AbstractPersistable<Long> implements AbstraticPojo {

	/**
	 * @author Denis
	 */
	private static final long serialVersionUID = 1L;
	
	private String login;
	private String senha;
	private List<Permissao> permissoes;
		
	@Override
	@Column(name = "id_login")
	@GeneratedValue
	@DocumentId
	public Long getId() {
		return super.getId();
	}
	
	@Column(name = "login")
	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}
	
	@Column(name = "senha")
	public String getSenha() {
		return senha;
	}

	public void setSenha(String senha) {
		this.senha = senha;
	}
	
	@ManyToMany
	@JoinTable(name = "login_has_permissao", joinColumns = { @JoinColumn(name = "id_login") }, inverseJoinColumns = { @JoinColumn(name = "id_permissao") })
	public List<Permissao> getPermissoes() {
		return permissoes;
	}

	public void setPermissoes(List<Permissao> permissoes) {
		this.permissoes = permissoes;
	}	
}
